<?php


namespace app\common\model;


use think\Model;

class Business extends Model
{
    public $tableName = '商家';                   // 数据表名称
    public $logId     = ['id'];     // 日志操作相关标识

    protected $table = "maniac_business";
    protected $createTime = "created_at";
    protected $updateTime = "updated_at";
    const STATUS_NO = 0;//未审核
    const STATUS_YES = 1;//已审核
    const STATUS_FAIL = 2 ;//拒绝
    protected $autoWriteTimestamp = "datetime";   // 自动写入时间戳
    //获取用户名称
    public function getMemberNameAttr($value,$data){
        return Members::field('id,nickname')->get($data['member_id'])->nickname;
    }
    //商家图片
    public function getBusinessIconUrlAttr($value,$data)
    {
        return $data['business_icon'] ? attach_uri($data['business_icon']) : '';
    }
    //审核状态
    public function getBusinessStatusTxtAttr($value,$data){
        $status = [0=>"未审核",1=>"已通过",2=>"未通过"];
        return $status[$data['status']];
    }
}